Test/ run-opts-configurable-host#3293
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3293 +/- ##
==========================================
- Coverage 54.74% 54.71% -0.03%
==========================================
Files 168 168
Lines 19605 19604 -1
==========================================
- Hits 10732 10726 -6
- Misses 7807 7813 +6
+ Partials 1066 1065 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/ok-to-test |
|
Hey @gauron99 , Please take a look on it . I added the suggestions of the preivous PR ( because that PR was messed up ). |
gauron99
left a comment
There was a problem hiding this comment.
Thanks! just a few naming nits. See below
pkg/functions/runner.go
Outdated
| if val == "" { | ||
| val = "localhost" | ||
| } | ||
| return val, "8080" |
There was a problem hiding this comment.
use the default values defined as variables for host and port. Also the TODO at the top of the file // TODO allow to be altered via a runOpt can be removed since we are adding this option to edit the host
|
Hey @gauron99 , Now is it good to go ? |
gauron99
left a comment
There was a problem hiding this comment.
Thanks for the cleanups. I reviewed the functionality and have some suggestions. I tested the functionality a little locally and I think my suggestions should cover all the cases. If you discover something Im missing please let me know!
| } | ||
| } | ||
|
|
||
| func TestParseAddress(t *testing.T) { |
There was a problem hiding this comment.
every case which has implicit defaulting should expect the defaultX variable value instead of hardcoded string so the test doesnt have to be re-written if the default changes
|
Hey @gauron99, PTAL now , Good eye btw :) |
| err io.Writer | ||
| } | ||
|
|
||
| func ParseAddress(val string) (host, port string, explicitPort bool) { |
There was a problem hiding this comment.
Since this is a "utility function" used only here, there's no need for it to be exported (can be just parseAddress)
There was a problem hiding this comment.
Hey @lkingland , but this function has been used in test file , so i made this ParseAddress
| ) | ||
|
|
||
| const ( | ||
| defaultRunHost = "127.0.0.1" // TODO allow to be altered via a runOpt |
There was a problem hiding this comment.
I believe this is still an outstanding TODO
There was a problem hiding this comment.
Arent we allowing the possibility to alter host with this flag? Or was the TODO for something more specific?
There was a problem hiding this comment.
Hey @lkingland , but now if a user will give his own Host then we have a function to adapt that host , so indirectly this todo has been solved .btw what do you think here ?
|
@intojhanurag I am a bit confused on this PR. It's labeled as a follow-up to #3275 but currently contains only a slight refactor. Is this intended to be a draft? |
No i think , i used a wrong word "follow up" , Actually in that PR initially i used totally differenct logic then Matej suggested diff idea , that i applied in that PR at that time . But again i thought to open a new PR 😭 because there was some issue locally regarding merge conflicts. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: intojhanurag The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
fc9cbfb to
f0f35b7
Compare
|
The parseAddress() function looks fine, but it won't be reachable by users because cmd/run.go (lines 419-438) validates the address using net.SplitHostPort() and rejects anything without both host and port before it ever reaches the new function here. Correct me if I am wrong, but I think we may need to update validateRunConfig() in cmd/run.go to remove the strict host+port requirement. Once that's done, users will actually be able to run func run --address 0.0.0.0 as I believe is intended. |
@lkingland , Yeah you are right . I tried locally , it is not working accordingly. what i should do now ? |
supersedes : #3275